package 一些算法竞赛测试题;

import java.util.*;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: a
 * Date: 2022-10-14
 * Time: 18:16
 */
public class Demo13 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int d = scan.nextInt();
        int k = scan.nextInt();
        Map<Integer, List<Integer>> map = new HashMap<>();
        while (n-- > 0) {
            int ts = scan.nextInt();
            int id = scan.nextInt();
            if (map.get(id) ==  null) {
                List<Integer> list = new ArrayList<>();
                map.put(id, list);
            }
            map.get(id).add(ts);
            map.put(id, map.get(id));
        }
        List<Integer> res = new ArrayList<>();
        for (Map.Entry<Integer, List<Integer>> entry : map.entrySet()) {
            List<Integer> list = entry.getValue();
            Collections.sort(list);
            int i = 0;
            while (i < list.size()) {
                int j = i + 1;
                int count = 1;
                while (j < list.size() && list.get(j) - list.get(i) < d) {
                    count++;
                    j++;
                }
                if (count >= k) {
                    res.add(entry.getKey());
                    break;
                } else {
                    i++;
                }
            }
        }
        Collections.sort(res);
        for (int i = 0; i < res.size(); i++) {
            System.out.println(res.get(i));
        }
    }
}
